//实现带权图需要这个类
public class Edge {
    //创建一个v->w的边
    private int v,w;
    public double weight;

    public Edge(int v,int w,double weight)
    {
      this.v=v;
      this.w=w;
      this.weight=weight;
    }

    //得到随便一个点
    //理想来说，v=either，w=e.other(v)
    public int either()
    {
      return v;
    }

    //得到v与哪个点相连接
    public int other(int V)
    {
       if(V==v)
       {
        return w;
       }
       else
       {
        return v;
       }
    }

    public int compareTo(Edge that)
    {
       if(this.weight>that.weight) return 1;
       else if(this.weight<that.weight) return -1;
       else return 0;
    }

    public double weight()
    {
      return weight;
    }
}
